package com.yin.myproject.hadoop.kpi.ips;

import com.yin.myproject.hadoop.BaseDriver;
import com.yin.myproject.hadoop.JobInitModel;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author Eason
 * @create 2018-03-27 11:01
 **/
public class IpsCount {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        String[] inPath = new String[]{"hdfs://localhost:9000/data/1-kpi/*"};
        String outPath = "hdfs://localhost:9000/out/1-kpi/ips";
        Configuration conf = new Configuration();
        String jobName = "ips";

        JobInitModel job = new JobInitModel(inPath, outPath, conf, null, jobName
                , IpsCount.class, null, Mapper.class, Text.class, Text.class, null, null, Reducer.class
                , Text.class, IntWritable.class);

        JobInitModel sortJob = new JobInitModel(new String[]{outPath + "/part-*"}, outPath + "/sort", conf, null
                , jobName + "sort", IpsCount.class, null, Mapper.class, Text.class, IntWritable.class, null, null, null, null, null);

        BaseDriver.initJob(new JobInitModel[]{job, sortJob});
    }
}
